﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

namespace ThoiTrangT2B
{
    public partial class GioiThieu : System.Web.UI.Page
    {
        string mod = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["mod"] != null)
            {
                mod = Request.QueryString["mod"].ToString();
                LoadNoiDung(mod);
            }
            LoadYahooList();
        }

        private void LoadYahooList()
        {
            string sql = "SELECT * FROM dbo.tblT2BDanhMuc WHERE MaDM = 'yahoo'";
            DataTable dt = SqlHelper.ExecuteDataTable(CommandType.Text, sql);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                ltrYahoo.Text += "<a href='ymsgr:sendim?" + dt.Rows[i]["TenDM"] + "'><img width='125' height='25' border='0' src='http://opi.yahoo.com/online?u=" + dt.Rows[i]["TenDM"] + "&m=g&t=2' style='border: 0px none;'></a><br /><br />";
            }
        }

        private void LoadNoiDung(string mod)
        {
            string sql = "SELECT TOP 1 * FROM dbo.tblT2BWebContent WHERE MaDM = @MaDM";
            List<SqlParameter> arrParams = new List<SqlParameter>();
            arrParams.Add(SqlHelper.CreateParameterObject("@MaDM", SqlDbType.NVarChar, ParameterDirection.Input, mod));
            DataTable dt = SqlHelper.ExecuteDataTable(CommandType.Text, sql, arrParams);
            if (dt.Rows.Count != 0)
            {
                ltrTitle.Text = dt.Rows[0]["TenDM"].ToString();
                ltrNoiDung.Text = dt.Rows[0]["NoiDung"].ToString();
            }
        }
    }

}
